package com.yoomiito.app.widget.dialog

import android.app.Activity
import android.content.Context
import androidx.appcompat.app.AppCompatActivity
import android.view.LayoutInflater
import android.view.View
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.TextView
import com.yoomiito.app.R
import com.yoomiito.app.model.sdd.SddFreeGoodsOrderInfo
import com.yoomiito.app.utils.DeviceConfigUtils
import com.yoomiito.app.utils.ImageLoader
import com.yoomiito.app.utils.ResUtil

/**
 * 是否赠送确认弹窗
 */
class SendGoodsDialog(mContext: Context,val data:SddFreeGoodsOrderInfo) :BaseDialog(mContext,R.style.dialog_2){

    var onResultListener:(Boolean)->Unit={}
    override fun setView(): View {
        val view = LayoutInflater.from(context).inflate(R.layout.dialog_send_goods,null,false)
        view.findViewById<ImageView>(R.id.close).setOnClickListener { dismiss() }
        view.findViewById<ImageView>(R.id.userHeadPic).let {
            ImageLoader.getInstance().into(mContext,data.headimgurl,it)
        }
        view.findViewById<TextView>(R.id.userNick).text = data.nickname
        view.findViewById<TextView>(R.id.inviterNick).text = "邀请人：${data.inickname}"
        view.findViewById<TextView>(R.id.goodsName).text = data.product_name
        view.findViewById<LinearLayout>(R.id.call).let {
            it.background = ResUtil.getDrawable(R.drawable.bg_border_f87fa9)
            it.setOnClickListener { DeviceConfigUtils.callTel(mContext as AppCompatActivity,data.mobile) }
        }
        view.findViewById<TextView>(R.id.phoneNum).let {
            it.text = data.mobile

        }
        view.findViewById<TextView>(R.id.item_cancel).let {
            it.paint.isFakeBoldText = true
            it.setTextColor(ResUtil.getColor(R.color.color_balk_333333))
            it.text = "拒绝赠送"
            it.setOnClickListener {
                onResultListener(false)
            }
        }
        view.findViewById<TextView>(R.id.item_sure).let {
            it.paint.isFakeBoldText = true
            it.setTextColor(ResUtil.getColor(R.color.color_FF035B))
            it.text = "同意赠送"
            it.setOnClickListener {
                onResultListener(true)
            }
        }
        setCanceledOnTouchOutside(true)
        setmHeightPercent(0.47)
        return view
    }

}